package org.gd.hellospring.injections;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.MethodReplacer;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author Gorhover
 * @version 1.0-SNAPSHOT
 * @since 2013-11-13 09:10
 */
@Component
class SimpleMethodReplacer implements MethodReplacer {

    @Autowired
    private User user;

    @Override
    public Object reimplement(Object o, Method method, Object[] objects) {
        switch (method.getName()) {
            case "getId":
                return user.getId();
            case "getName":
                return user.getName();
        }
        return null;
    }
}
